package com.cqut.familiarity.handler;


import com.cqut.familiarity.exception.LoginException;
import com.cqut.familiarity.utils.ResultEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 *
 * @author weitao
 * @since 2021-05-23
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    /**
     * 登录异常
     */
    @ExceptionHandler(LoginException.class)
    public ResultEntity loginException(LoginException e){
        log.error(e.getMessage(),e);
        return ResultEntity.error().data("error",e.getMessage());
    }



}
